package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishFlavorsMapper {
    /**
     * 在菜品口味表中批量插入数据
     *
     * @param flavors
     */
    void insertBatch(List<DishFlavor> flavors);

    /**
     * 删除菜品关联的口味数据
     *
     * @param dishIds
     */
    void deleteByDishIds(List<Long> dishIds);   /*批量删除*/

    @Delete("delete from dish_flavor where dish_id = #{dishId}")    /*单个删除*/
    void deleteByDishId(Long dishId);

    /**
     * 根据菜品id查询其口味
     *
     * @param dishId
     * @return
     */
    @Select("select id, dish_id, name, value from dish_flavor where dish_id = #{dishId};")
    List<DishFlavor> getByDishId(Long dishId);
}
